package qqgroupdata.process.common;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class JsonResult {
    String code;
    String msg;
    Object data;

    public static JsonResult success(String code, String msg, Object data) {
        JsonResult j = new JsonResult(code, msg, data);
        return j;
    }

    public static JsonResult success() {
        JsonResult j = new JsonResult("0000", "success", null);
        return j;
    }

    public static JsonResult success(Object data) {
        JsonResult j = new JsonResult("0000", "success", data);
        return j;
    }

    public static JsonResult success(String msg, Object data) {
        JsonResult j = new JsonResult("0000", msg, data);
        return j;
    }

    public static JsonResult error(Throwable e) {
        JsonResult j = new JsonResult("9999", "error", e);
        return j;
    }

    public static JsonResult error(String msg) {
        JsonResult j = new JsonResult("9999", msg, null);
        return j;
    }
}
